<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <h:head />
    <h:body>
        <ui:composition template="template.xhtml">
            
            <ui:define name="title">
                User Profile
            </ui:define>
                
            <ui:define name="content">
                <!--______________ MAIN CONTENT ______________-->
                <h:form>
                    <h:panelGrid columns="2">
                        <h:outputLabel for="name" value = "Name:"/>
                        <h:outputLabel id ="name" value = "#{scheduleView.user.name}"/>
                                
                        <h:outputLabel for="surname" value = "Surname:"/>
                        <h:outputLabel id ="surname" value = "#{scheduleView.user.surname}"/>
                                
                        <h:outputLabel for="birthday" value = "Birthday:"/>
                        <h:outputLabel id ="birthday" value = "#{scheduleView.user.birthday}">
                            <f:convertDateTime pattern="dd.MM.yyyy"  timeZone="GMT+1"/>
                        </h:outputLabel>
                                
                        <h:outputLabel for="phoneNumber" value = "Phone Number:"/>
                        <h:outputLabel id ="phoneNumber" value = "#{scheduleView.user.phoneNumber}"/>
                                
                        <h:outputLabel for="residenceTown" value = "Residence Town:"/>
                        <h:outputLabel id ="residenceTown" value = "#{scheduleView.user.residenceTown}"/>
                                
                        <h:outputLabel for="email" value = "Email:"/>
                        <h:outputLabel id ="email" value = "#{scheduleView.user.email}"/>
                                
                    </h:panelGrid>
                </h:form>
                <h:form>
                    <h3>Calendar</h3>
                    <p:schedule value="#{scheduleView.loggedUserEvents}" draggable="false" ignoreTimezone="false" resizable="false" >
                        <p:ajax event="eventSelect" listener="#{scheduleView.onEventSelect}" update="eventDetails" oncomplete="PF('eventDialog').show();" />
                    </p:schedule>
                    <p:dialog widgetVar="eventDialog" header="Event Details" showEffect="clip" hideEffect="clip">
                        <h:panelGrid id="eventDetails" columns="2" >
                            <h:outputLabel for="title" value="Title:"  rendered="#{scheduleView.event.data!=null}"/>
                            <h:outputText id="title" value="#{scheduleView.event.title}"  rendered="#{scheduleView.event.data!=null}"/>
                                    
                            <h:outputLabel for="from" value="From:" />
                            <h:outputText id="from" value="#{scheduleView.event.startDate}">
                                <f:convertDateTime pattern="dd/MM/yyyy  HH:mm:ss" timeZone="GMT+1"/>
                            </h:outputText>
                                    
                            <h:outputLabel for="to" value="To:" />
                            <h:outputText id="to" value="#{scheduleView.event.endDate}">
                                <f:convertDateTime pattern="dd/MM/yyyy  HH:mm:ss" timeZone="GMT+1"/>
                            </h:outputText>
                            
                            <h:outputLabel for="notPredefinedTypology" value="Typology:" rendered="#{scheduleView.event.data!=null and scheduleView.event.data.predefinedTypology == 'other'}"/> 
                            <h:outputLabel id="notPredefinedTypology" value="#{scheduleView.event.data.notPredefinedTypology}" rendered="#{scheduleView.event.data!=null and scheduleView.event.data.predefinedTypology == 'other'}"/>
                            
                            <h:outputLabel for="predefinedTypology" value="Typology: " rendered="#{scheduleView.event.data!=null and scheduleView.event.data.predefinedTypology != 'other'}"/> 
                            <h:outputLabel id="predefinedTypology" value="#{scheduleView.event.data.predefinedTypology}" rendered="#{scheduleView.event.data!=null and andscheduleView.event.data.predefinedTypology != 'other'}"/>               
                            
                            <h:outputLabel for="outdoor" value="Outdoor:" rendered="#{scheduleView.event.data!=null}"/> 
                            <h:outputLabel id="outdoor" value="#{scheduleView.event.data.outdoor}" rendered="#{scheduleView.event.data!=null}"/>
                            
                            <h:outputLabel for="weatherForecast" value="Weather Forecast:" rendered="#{scheduleView.event.data!=null and scheduleView.event.data.weatherForecast != null}"/>
                            <p:graphicImage id="weatherForecast" value="http://openweathermap.org/img/w/#{scheduleView.event.data.weatherForecast.icon}.png" rendered="#{scheduleView.event.data!=null and scheduleView.event.data.weatherForecast != null}"/>
                            
                            <h:outputLabel for="tempForecast" value="Temperature Forecast:" rendered="#{scheduleView.event.data!=null and scheduleView.event.data.weatherForecast != null}"/>
                            <h:outputLabel id="tempForecast" value="#{scheduleView.event.data.weatherForecast.temperatureFormat} °C" rendered="#{scheduleView.event.data!=null and scheduleView.event.data.weatherForecast != null}"/>
                            
                            <br/>
                            <h:outputLabel id="rainForecasted" value="Expected rain" rendered="#{scheduleView.event.data!=null and scheduleView.event.data.weatherForecast != null 
                                                                                                   and scheduleView.event.data.weatherForecast.precipitation == true}"/>
                            
                            <h:outputLabel id="NOrainForecasted" value="NO expected rain" rendered="#{scheduleView.event.data!=null and scheduleView.event.data.weatherForecast != null 
                                                                                                        and scheduleView.event.data.weatherForecast.precipitation == false}"/>
                            
                            <h:outputLabel for="windForecast" value="Wind Forecast:" rendered="#{scheduleView.event.data!=null and scheduleView.event.data.weatherForecast != null}"/>
                            <h:outputLabel id="windForecast" value="#{scheduleView.event.data.weatherForecast.wind} m/s" rendered="#{scheduleView.event.data!=null and scheduleView.event.data.weatherForecast != null}"/>
                            
                            <h:commandButton value="View Event" action="#{scheduleView.goToEvent(scheduleView.event.data)}"  rendered="#{scheduleView.event.data!=null}"/>
                            <h:outputLabel id="privateEvent" value="PRIVATE EVENT: you can't see more information about this event" rendered="#{scheduleView.event.data == null}"/>
                            
                        </h:panelGrid>
                    </p:dialog>    
                </h:form>
            </ui:define>
                
        </ui:composition>
    </h:body>
</html>

